/**
 * fileName:com.zimo.web.util.ImageType.java
 * projectName:Zimo
 */
package com.zimo.web.util;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;

/**
 * 
 * @author sg.z/2013-12-23/下午5:46:41
 */
public class ContentTypeUtil {

	private static List<String> imgList = new ArrayList<String>();
	static {
		imgList.add("image/bmp");
		imgList.add("image/gif");
		imgList.add("image/jpeg");
		imgList.add("image/png");
	}
	private static List<String> audioList = new ArrayList<String>();
	static {
		audioList.add("audio/mpeg");
		audioList.add("audio/x-ms-wma");
	}

	private static List<String> videoList = new ArrayList<String>();
	static {
		videoList.add("video/x-ms-wmv");
		videoList.add("video/x-ms-wm");
		videoList.add("video/mpeg4");
	}

	/**
	 * 是否包含该文件类型 description :
	 * 
	 * @return boolean
	 * @param type 对比的文件类型 img,audio和video三种
	 * @param contentType 响应头信息
	 * @return
	 * @author sg/2013-12-23/下午5:53:54
	 */
	public static boolean contains(String type, String contentType) {
		if (StringUtils.equals("img", type)) {
			if (imgList.contains(contentType))
				return true;
		} else if (StringUtils.equals("audio", type)) {
			if (audioList.contains(contentType))
				return true;
		} else if (StringUtils.equals("video", type)) {
			if (videoList.contains(contentType))
				return true;
		}
		return false;
	}

}
